﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using ReceiptPrint.Models;


namespace ReceiptPrint.ViewModels.CommodityTypeVMs
{
    public partial class CommodityTypeListVM : BasePagedListVM<CommodityType_View, CommodityTypeSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"", dialogWidth: 800),
                this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "", dialogWidth: 800),
                this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "", dialogWidth: 800),
                //this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "", dialogWidth: 800),
                //this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "", dialogWidth: 800),
                //this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "", dialogWidth: 800),
                //this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "", dialogWidth: 800),
                //this.MakeStandardAction("CommodityType", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], ""),
            };
        }


        protected override IEnumerable<IGridColumn<CommodityType_View>> InitGridHeader()
        {
            return new List<GridColumn<CommodityType_View>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.Tax),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<CommodityType_View> GetSearchQuery()
        {
            var query = DC.Set<CommodityType>()
                .CheckContain(Searcher.Name, x => x.Name)
                .Select(x => new CommodityType_View
                {
				    ID = x.ID,
                    Name = x.Name,
                    Tax = x.Tax,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class CommodityType_View : CommodityType{

    }
}
